package com.hhkj.admin.train.domain;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BizBaseEntity;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.mybatis.handler.StringListHandler;
import com.ruoyi.common.valid.VEdit;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 练习作答题目对象 t_train_question
 *
 * @author ruoyi
 * @since 2023-05-24
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value = "t_train_student_answer", autoResultMap = true)
@NoArgsConstructor
@AllArgsConstructor
public class TrainStudentAnswer extends BizBaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 练习表id,关联t_train表主键 */
    @Excel(name = "练习表id,关联t_train表主键")
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private Long trainId;

    /** 学生id */
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private Long studentId;

    /** 题目id */
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private Long questionId;

    /** 学生作答答案 */
    @Excel(name = "学生作答答案")
    private String studentAnswer;

    /** 批改结果标签 正确 right 错误 error 部分正确 partRight 未作答 unanswered */
    @Excel(name = "批改结果标签 正确 right 错误 error 部分正确 partRight 未作答 unanswered")
    private String correctResCode;

    /** 排序字段 */
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private Integer orderNum;

    /** 题目分数 */
    private BigDecimal questionMark;

    /** 学生得分 */
    private BigDecimal studentMark;

    /** 选项排序顺序列表 */
    @TableField(typeHandler = StringListHandler.class)
    private List<String> actualOptionOrderList;

    @JsonIgnore
    @Override
    public Map<String, Object> getParams()
    {
        return super.getParams();
    }

    @JsonIgnore
    @Override
    public PageDomain getPageDomain()
    {
        return super.getPageDomain();
    }

    public TrainStudentAnswer(Long studentId, Long questionId, String studentAnswer, String correctResCode, Integer orderNum)
    {
        this.studentId = studentId;
        this.questionId = questionId;
        this.studentAnswer = studentAnswer;
        this.correctResCode = correctResCode;
        this.orderNum = orderNum;
    }

    public TrainStudentAnswer(Long questionId, String studentAnswer, String correctResCode, Integer orderNum, BigDecimal questionMark, BigDecimal studentMark, List<String> actualOptionOrderList)
    {
        this.questionId = questionId;
        this.studentAnswer = studentAnswer;
        this.correctResCode = correctResCode;
        this.orderNum = orderNum;
        this.questionMark = questionMark;
        this.studentMark = studentMark;
        this.actualOptionOrderList = actualOptionOrderList;
    }

    @Override
    @NotNull(message = "唯一主键不能为空", groups = {VEdit.class})
    public Long getId()
    {
        return super.getId();
    }


}
